<template>
  <div id="app">
    <button @click="addAge">点我更新仓库</button>
    <div>
      我现在的年龄是
      <span>
        {{ $store.state.user_age }}
      </span>
    </div>
    <Demo></Demo>
    <Demo2></Demo2>
  </div>
</template>

<script>
import Demo from "./demo.vue";
import Demo2 from "./demo2.vue";
export default {
  name: "App",
  components: {
    Demo,
    Demo2,
  },
  methods: {
    addAge() {
      console.log(this.$store);
      // this.$store.commit("setAge", 10);
      // 通过组件去触发dispatch
      this.$store.dispatch("setUserage", this.$store.state.user_age + 10);
    },
  },
};
</script>
